package bb.action;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import io.vertx.ext.web.RoutingContext;

@Controller
public class UserAction {

	public void login(RoutingContext ctx) {

		StringBuffer sb = new StringBuffer();

		Connection connection = ctx.get("conn");
		Statement stmt;
		try {
			stmt = connection.createStatement();
			ResultSet rs = stmt.executeQuery("select *from user");
			while (rs.next()) {
				sb.append(rs.getObject(1)).append(",");
				sb.append(rs.getObject(2)).append(",");
				sb.append(rs.getObject(3));
				ctx.response().putHeader("content-type", "text/html;charset=UTF-8").end("login success" +sb.toString());
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}
